from config import INPUT_WIDTH, CHANNEL_DBG

def row_equal(row1, row2):
    return all([i == j for i, j in zip(row1, row2)])


def row_add(row1, row2):
    return [i ^ j for i, j in zip(row1, row2)]


def get_rows_amount():
    """
        rows contain:
            a row filled with ones
            `width` rows of input bits
            `width` rows of output bits
            `width` * `width` rows of monomials
    """
    return 1 + 2 * INPUT_WIDTH + INPUT_WIDTH * INPUT_WIDTH


def get_cols_amount():
    return 2 ** INPUT_WIDTH


def info(channel, msg):
    """
        a helper function that manages all the information to be output
    """
    switch = {
        CHANNEL_DBG: True
    }

    if switch[channel]:
        print '%s: %s' % (channel, msg)


def print_matrix(m):
    """
        pretty-print the entire matrix
    """
    print '-' * (3 * (len(m[0]) + 2))
    for cnt, i in enumerate(m):
        print '{0:-2d}'.format(cnt), i



